#pragma once

//////////////////////////////////////////////////////////////////////////
//////			算法性能测试										//////
//////////////////////////////////////////////////////////////////////////
#include <windows.h>
class Performance
{
public:
	Performance(void)
	{
		QueryPerformanceFrequency(&m_CounterFrequency);
	}

	void Reset()
	{
		QueryPerformanceCounter(&m_ResetTime);
	}

	float GetTime(bool reset=false)
	{ 
		return ComputeTime(reset)*1.0f;
	};
	float GetTimeMilli(bool reset=false)	
	{ 
		return ComputeTime(reset)*1000.0f; 
	};
	float GetTimeMicro(bool reset=false)
	{ 
		return ComputeTime(reset)*1000000.0f; 
	};

protected:
	float ComputeTime(bool reset)
	{
		double dCount = double(m_ResetTime.QuadPart);
		LARGE_INTEGER curTime;
		QueryPerformanceCounter(&curTime);
		double diffTime = double(curTime.QuadPart - m_ResetTime.QuadPart);
		if (reset)
		{
			m_ResetTime = curTime;
		}
		return float(diffTime/m_CounterFrequency.QuadPart);
	}

private:
	LARGE_INTEGER m_CounterFrequency;
	LARGE_INTEGER m_ResetTime;
};
